//顶部tab信息
export const tabArr = [
  {
    key: '1',
    tab: '待还账期',
  },
  {
    key: '2',
    tab: '未出账期',
  },
  {
    key: '3',
    tab: '历史账期',
  },
];

//表单配置项
const formItemData = {
  'contractNo': {
    itemConfig: {
      name: 'contractNo'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '合同编号',
    }
  },
  'storeId': {
    itemConfig: {
      name: 'storeId'
    },
    elConfig: {
      formType: 'storeNameSearch',
      placeholder: '供应商',
    }
  },
  'inputGroup': {
    formType: 'inputGroup',
    items: [
      {
        itemConfig: {
          name: 'timeType'
        },
        elConfig: {
          formType: 'noLabelSelect',
          placeholder: '时间类型',
          options: [
            { label: '出账时间', value: '1' },
            { label: '最终还款日', value: '2' },
          ],
          style: {
            width: '100px'
          }
        }
      },
      {
        itemConfig: {
          name: 'payTime'
        },
        elConfig: {
          formType: 'noLabelRangTime',
          placeholder: ['开始时间', '结束时间'],
          style: {
            width: '332px'
          }
        }
      },
    ],
  },
  'overdueState': {
    itemConfig: {
      name: 'overdueState'
    },
    elConfig: {
      formType: 'Select',
      placeholder: '是否逾期',
      options: [
        { label: '未逾期', value: '2' },
        { label: '已逾期', value: '1' },
      ]
    }
  },
  'disRemark': {
    itemConfig: {
      name: 'disRemark'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '备注',
    }
  },
}

//处理表单数据
export const getFormItem = (storeName, changeStoreName, type) => {
  const arr = [];
  Object.keys(formItemData).map(v => {
    if(type != '1' && ['overdueState', 'disRemark'].includes(v)) {
      return;
    }
    if(type == 2 && v == 'inputGroup') {
      return;
    }
    if(v == 'storeId') {
      formItemData[v].elConfig.storeName = storeName;
      formItemData[v].elConfig.onChange = changeStoreName;
    }
    arr.push(formItemData[v]);
  })
  return arr;
}